package com.example.zz.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.zz.entity.Attestation;
import com.example.zz.service.IAttestationService;
import com.example.zz.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户认证 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/admin/user/attestation")
public class AttestationController {

    @Autowired
    IAttestationService attestationService;

    /**
     * 查找用户审核认证
     * @param page
     * @param limit
     * @param role
     * @return
     */
//    @ResponseBody
    @GetMapping("/userAttestation")
    public PageVO<Attestation> seletUserAttestation(Integer page, Integer limit, Integer role){
        Page pages=new Page(page,limit);
        return attestationService.seletAttestationPageByRole(pages,role);

    }

    /**
     * 设置审核结果
     * @param result
     * @return
     */
    @GetMapping("/verifyResult")
    public R verifyResult(Long id,Integer role ,Integer result){
        int n=attestationService.updateAttestationResult(id,role,result);
        R r=new R();
        if (n==1){
            r.setCode(200);
            r.setMsg("审核成功");
        }else {
            r.setCode(202);
            r.setMsg("审核失败");
        }
        return r;
    }

    /**
     * 按照审核状体查找用户认证信息
     * @param result
     * @return
     */
    @GetMapping("/seletAttestationByResult")
    public PageVO<Attestation> seletAttestationByResult(Integer page, Integer limit,Integer role, Integer result){
        Page pages=new Page(page,limit);
        return attestationService.seletAttestationByResult(pages,role,result);
    }
}

